home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / music / musgfa.zoo / musedt.lst < prev    next >
File List  |  1992-12-24  |  54KB  |  2,046 lines

  1. ' musedt.gfa  6 June 1991: graphics envelope added 3 may 92
  2. ' music scoring software
  3. ' programmed by Seymour Shlien in GFA Basic 3.5 on my 1040STE
  4. ' 624 Courtenay Avenue / Ottawa, Ontario, Canada  K2A 3B5
  5. ' The program is public domain and not for commercial use.
  6. DIM note_yposition%(52) ! vertical of natural notes on staff
  7. DIM flat_yposition%(22),sharp_yposition%(22) ! vertical position of other notes
  8. DIM length_sprite%(12) !mapping of note time value with its sprite number
  9. DIM rest_sprite%(12) !mapping of rest time value with its sprite number
  10. DIM sharp_key_to_letter$(13) !mapping of pitch code (1 to 12) to letter code
  11. DIM flat_key_to_letter$(13) ! mapping of pitch code to letter code (c,d,e...g)
  12. DIM duration_to_text$(17) !duration code (0 to 12) to symbol (eg HN.)
  13. DIM keysig_to_text$(15) !key signature code (1 to 12) to text
  14. DIM assumed_accidental%(12) ! indicates whether note must be preceded by #,b
  15. DIM nat_keys%(15) !keys to be printed as natural as function of key signature
  16. DIM shrp_keys%(15) !keys assumed to be accidentals as function of keysig
  17. DIM sharp_sig_ypos%(7),flat_sig_ypos%(7)  ! treble and bass sharp sequence
  18. DIM notes_to_microbeats%(12) ! duration code (1 - 12) to microbeat value
  19. DIM elapsed_microbeats%(3) !number of microbeats for each voice (bar lines)
  20. DIM sprite$(30)
  21. DIM seq%(3) !note sequence number in each voice during play
  22. DIM micro_beat%(3) ! accumulated microbeats for voice (for play)
  23. DIM next_event%(3) ! time for next note to sound for voice (for play)
  24. DIM play_stop%(3) ! kounter for stop playing -used in cue
  25. DIM note_tick%(3) ! time a note was sounded. Used for envelope
  26. DIM tone_envel%(300) ! loudness envelope 1 to 100 for each voice
  27. DIM volum(3),decay(3)
  28. DIM voice_end_flag%(3) ! flag to signal end of voice
  29. DIM note%(3),duration%(3),draw_flag%(3) !last notes sounded
  30. DIM black_keys%(5) ! position of black keys on keyboard
  31. REM white key - black key to pitch code converter
  32. DIM white_keycod%(7),black_keycod%(7),white_key_decoder%(32),black_key_decoder%(21)
  33. DIM x1%(50),x2%(50),y1%(50),y2%(50) ! for mouse sensitive zones
  34. DIM kount%(2),vclen%(2),repeat_sign%(2),repeat_count%(2)
  35. REM memory for storing music
  36. DIM tnote&(2,1000),mubeat%(3)
  37. DIM last_note_duration%(3) !need it if we correct an error with right button
  38. REM if USESHARPS = 1 then sharps are used instead of flats
  39. usesharps%=0
  40. DEFMOUSE 0
  41. CLS
  42. rez%=XBIOS(4)
  43. IF rez%<>1
  44.   ALERT 3," Please switch to | medium resolution! ",1,"Oops",b%
  45.   STOP
  46. ENDIF
  47. CLS
  48. IF usesharps%<>1
  49.   usesharps%=1
  50. ELSE
  51.   usesharps%=0
  52. ENDIF
  53. key_sig%=8 ! key signature for c major (a minor)
  54. beats_per_bar%=4
  55. beat_size%=4
  56. bar_length%=beats_per_bar%*notes_to_microbeats%(beat_size%)
  57. next_bar_line%=bar_length%
  58. next_key_sig%=8
  59. tnt%=11 ! assume quarter note sprite
  60. staff_yshift%=-25 !vertical position to draw treble and bass staff
  61. voic%=1
  62. voic1%=voic%-1
  63. speed%=50
  64. @read_music_data
  65. @load_note_sprites
  66. @initialize_note_table
  67. volum(0)=11
  68. volum(1)=10
  69. volum(2)=10
  70. decay(0)=0.08
  71. decay(1)=0.09
  72. decay(2)=0.13
  73. FOR i%=0 TO 2
  74.   offset=volum(i%)
  75.   attenuation=decay(i%)
  76.   @make_tone_envelope(i%,offset,attenuation)
  77. NEXT i%
  78. @draw_musedt_screen
  79. @reset
  80. tlen%=4
  81. @switch_note_duration
  82. note_xcoor%=40
  83. ' run till infinity
  84. FOR i%=1 TO 500000
  85.   @decode_mouse_key
  86.   PAUSE 10
  87.   IF write%=1
  88.     IF klick%=1 !appending or overwriting next note
  89.       kount%(voic1%)=kount%(voic1%)+1
  90.       tnote&(voic1%,kount%(voic1%))=nte%+tlen%*256
  91.       last_note_duration%(voic1%)=tlen%
  92.       IF tlen%<13
  93.         elapsed_microbeats%(voic1%)=elapsed_microbeats%(voic1%)+notes_to_microbeats%(tlen%)
  94.       ENDIF
  95.       IF (elapsed_microbeats%(voic1%)>next_bar_line%)
  96.         @new_bar_line
  97.         note_xposition%=next_note_xposition%
  98.       ENDIF
  99.       IF next_note_xposition%>595 THEN
  100.         @show
  101.       ELSE
  102.         @draw_note_on_staff(next_note_xposition%,1)
  103.       ENDIF
  104.       @sound_note
  105.       @update_editor_windows
  106.       IF kount%(voic1%)>vclen%(voic1%)
  107.         vclen%(voic1%)=kount%(voic1%)
  108.         '  @show
  109.       ENDIF
  110.     ENDIF
  111.     IF klick%=2 !   right button for correcting the last note keyed in
  112.       tnote&(voic1%,kount%(voic1%))=nte%+tlen%*256
  113.       IF tlen%<>last_note_duration%(voic1%)
  114.         elapsed_microbeats%(voic1%)=elapsed_microbeats%(voic1%)-notes_to_microbeats%(last_note_duration%(voic1%))
  115.         elapsed_microbeats%(voic1%)=elapsed_microbeats%(voic1%)+notes_to_microbeats%(tlen%)
  116.         last_note_duration%(voic1%)=tlen%
  117.       ENDIF
  118.       @show
  119.       @sound_note
  120.       @update_editor_windows
  121.     ENDIF
  122.   ENDIF
  123.   IF klick%=0
  124.     @ascii_code_dispatcher
  125.   ENDIF
  126.   IF ky%=38
  127.     @execute_menu_command
  128.   ENDIF
  129.   IF ky%>33 AND ky%<37 !process repeat signs
  130.     draw_marker(ky%-32,next_note_xposition%)
  131.     INC kount%(voic1%)
  132.     IF kount%(voic1%)>vclen%(voic1%)
  133.       vclen%(voic1%)=kount%(voic1%)
  134.     ENDIF
  135.     tnote&(voic1%,kount%(voic1%))=256*(ky%-21)
  136.   ENDIF
  137. NEXT i%
  138. > PROCEDURE tnote_structure_doc
  139.   ' tnote array stores the pitch and duration value of every note
  140.   ' to be played for the three voices (tracks). The high byte contains
  141.   ' the duration code and other special codes. The low byte contains
  142.   ' the pitch code. The pitch code modulo 12 maps into the note letter
  143.   ' c,c#,d,d#,... b. If the pitch code is zero then a rest is assumed.
  144.   ' The duration code 0 to 12 map to note duration in the order that
  145.   ' the note duration sprites appear in the menu. Other codes 13 to 15
  146.   ' control repeats. Codes 16 and 17 are not fully implemented but allow
  147.   ' the inclusion of long rests in a particular voice. Other codes are
  148.   ' only used for the input /output files *.TUN for specifying key signature,
  149.   ' time signature, and tempo.
  150. RETURN
  151. > PROCEDURE note_sprites_doc
  152.   ' order of sprites in the sprite array is: 1 c-cleff, 2 bass-cleff
  153.   ' 3 flat symbol for tail up note, 4 flat symbol for tail down, 5,6 sharp
  154.   ' symbol (tail up and down), 7,8 whole note symbol, 9,10 half note symbol
  155.   ' 11,12 quarter note symbol, 13,14 eighth note symbol, 15,16 sixteenth note
  156.   ' 17,18 32nd node, 19-25 rest symbols, 26,27 natural symbol.
  157. RETURN
  158. > PROCEDURE load_note_sprites
  159.   LOCAL loop%
  160.   OPEN "i",#1,"notes2.put"
  161.   FOR loop%=1 TO 29
  162.     sprite$(loop%)=INPUT$(CVI(INPUT$(2,#1)),#1)
  163.   NEXT loop%
  164.   CLOSE #1
  165. RETURN
  166. > PROCEDURE read_music_data
  167.   @read_note_positions
  168.   @read_note_duration_sprite_numbers
  169.   @read_rest_duration_sprite_numbers
  170.   @read_key_to_letter_converter
  171.   @read_note_duration_code
  172.   @read_key_signature_representation
  173.   @read_order_of_flats_and_sharps
  174.   @read_signature_sharp_sequence
  175.   @read_timconv_array
  176.   @read_key_decoders
  177. RETURN
  178. > PROCEDURE read_note_positions
  179.   LOCAL i%
  180.   REM read the vertical position to display the note sprites on
  181.   REM the treble or bass staff.
  182.   REM negative numbers are pointers to sharp or flat notes.
  183.   FOR i%=1 TO 49
  184.     READ note_yposition%(i%)
  185.   NEXT i%
  186.   FOR i%=1 TO 21
  187.     READ flat_yposition%(i%)
  188.   NEXT i%
  189.   FOR i%=1 TO 20
  190.     READ sharp_yposition%(i%)
  191.   NEXT i%
  192.   DATA 67,-1,65,-2,62,-3,60,58,-4,55
  193.   DATA -5,63,61,-6,59,-7,56,-8,54,52
  194.   DATA -9,32,-10,30,28,-11,25,-12,23,-13
  195.   DATA 20,28,-14,26,-15,23,21,-16,19,-17
  196.   DATA 17,-18,15,13,-19,11,-20,9,-21
  197.   REM
  198.   DATA 65,62,60,55,63,59,57,54,32,30
  199.   DATA 25,23,20,26,23,19,17,15,11,9
  200.   DATA 7
  201.   REM
  202.   DATA 67,65,62,58,55,61,59,56,52,32
  203.   DATA 28,25,23,28,26,21,19,17,13,11
  204. RETURN
  205. > PROCEDURE read_note_duration_sprite_numbers
  206.   LOCAL i%
  207.   FOR i%=0 TO 12
  208.     READ length_sprite%(i%)
  209.   NEXT i%
  210.   DATA 17,15,13,13,11,11,9,9,7,7,17,15,13
  211.   ltlen%=4
  212. RETURN
  213. > PROCEDURE read_rest_duration_sprite_numbers
  214.   LOCAL i%
  215.   FOR i%=0 TO 12
  216.     READ rest_sprite%(i%)
  217.   NEXT i%
  218.   DATA 24,23,22,22,21,21,20,20,19,19,24,23,22
  219. RETURN
  220. > PROCEDURE read_key_to_letter_converter
  221.   LOCAL i%
  222.   FOR i%=1 TO 12
  223.     READ sharp_key_to_letter$(i%)
  224.   NEXT i%
  225.   FOR i%=1 TO 12
  226.     READ flat_key_to_letter$(i%)
  227.   NEXT i%
  228.   DATA "C","C#","D","D#","E","F","F#","G","G#","A","A#","B"
  229.   DATA "C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"
  230. RETURN
  231. > PROCEDURE read_note_duration_code
  232.   LOCAL i%
  233.   FOR i%=0 TO 17
  234.     READ dur